package base;

public class encryption_and_decrypt {
    public static void main(String[] args) {
        //1.整数计算出数组长度
        int number = 77489,temp = number;
        int count = 0; //统计变量
        while (number != 0){
            number = number / 10;
            count++;
        }
        System.out.println(count);
        //2.动态初始化 数组
        int[] arr = new int[count];
        //3.把整数添加到数组中
        int index = arr.length-1;
        while (temp != 0){
            arr[index] = temp % 10;
            temp = temp / 10;
            index--;
        }
        //加密 数组+5，对10取余，反转。
        for (int i = 0; i < arr.length; i++) {
            arr[i] += 5;
        }
        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] % 10;
        }
        for(int i=0,j=arr.length-1;i<j;i++,j--){
            int get = arr[i];
            arr[i] = arr[j];
            arr[j] = get;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
        }System.out.print("\n");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //解密@@
        for (int i = 0,j = arr.length-1; i < j; i++,j--) {
            int temp1 = arr[i];
            arr[i] = arr[j];
            arr[j] = temp1;
        }
        for (int i = 0; i < arr.length; i++) {    //+5后的数取值为 5 ~14
            if (arr[i] >=0 && arr[i] <= 4){
                arr[i] = arr[i] + 10;
            }
        }
        for (int i = 0; i < arr.length; i++) {
            arr[i] -= 5;
        }
        int number1 = 0;
        for (int i = 0; i < arr.length; i++) {
            number1 = number1 *10 +arr[i];
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
        }
    }
}
